import java.util.Stack;

public class Test {


    public boolean IsPopOrder(int[] pushV, int[] popV) {
        Stack<Integer> stack = new Stack<>();
        int j = 0;
        for (int i = 0; i < pushV.length; i++) {
            stack.push(pushV[i]);
            while (j > 0 && j < stack.size() && stack.peek() == popV[j]) {
                stack.pop();
            }
        }
        return stack.empty();
    }


    class MinStack {
        public Stack<Integer> stack;
        public Stack<Integer> minstack;

        public MinStack() {
            stack = new Stack<>();
            minstack = new Stack<>();
        }

        public void push(int val) {
            stack.push(val);
            if (minstack.empty()) {
                minstack.push(val);
            } else {
                if (val <= minstack.peek()) {
                    minstack.push(val);
                }
            }
        }

        public void pop() {
            if (stack.empty()&&minstack.empty()){
                return;
            }
            if (stack.peek()>minstack.peek()){
                stack.pop();
            }else{
                stack.pop();
                minstack.pop();
            }
        }

        public int top() {
            return stack.peek();
        }

        public int getMin() {
            return minstack.peek();
        }
    }
}
